package com.github.jspxnet.worktask.listener;


import com.github.jspxnet.worktask.table.WorkTask;

import java.util.ArrayList;
import java.util.List;

public class TaskListenerManager {
    private final static List<TaskListener> LISTENERS = new ArrayList<>();
    final static private TaskListenerManager INSTANCE = new TaskListenerManager();
    public static TaskListenerManager getInstance() {
        return INSTANCE;
    }

    public TaskListenerManager()
    {
        LISTENERS.add(new AnnotationTaskListener());
    }

    public void register(TaskListener taskListener)
    {
        LISTENERS.add(taskListener);
    }

    public List<TaskListener> getListeners()
    {
        return LISTENERS;
    }

    public void notifyAll(WorkTask task)
    {
         for (TaskListener taskListener:LISTENERS)
         {
             taskListener.notify(task);
         }
    }
}
